import '../compact_dio.dart';

class CompactDio {
  /// Sends a GET request to the specified [path] and returns a [Future] that resolves
  /// to a [CompactDioResult] containing the response data of type [R].
  ///
  /// [params] is an optional map of query parameters to include in the request.
  /// [baseUrl] is an optional base URL to use for the request.
  /// [dialog] is an optional boolean that determines whether to show a loading dialog.
  /// [decoder] is an optional [BaseDecoder] to use for decoding the response data.
  /// [decodeType] is an optional type parameter [T] used for decoding the response data.
  /// [contentType] is an optional content type to set for the request.
  /// [cancelToken] is an optional [CancelToken] that can be used to cancel the request.
  /// [onSendProgress] is an optional callback that is called periodically with the number of bytes sent.
  /// [onReceiveProgress] is an optional callback that is called periodically with the number of bytes received.
  static Future<CompactDioResult<R>> get<R, T>(
    String path, {
    Map<String, dynamic>? params,
    String? baseUrl,
    bool? dialog,
    BaseDecoder? decoder,
    T? decodeType,
    String? contentType,
    CancelToken? cancelToken,
    ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
  }) {
    return CompactDioProxy.instance.get<R, T>(
      path,
      params: params,
      baseUrl: baseUrl,
      dialog: dialog,
      decoder: decoder,
      type: decodeType,
      cancelToken: cancelToken,
      contentType: contentType,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );
  }

  /// Sends a POST request to the specified [path] with the given [data] and returns a [Future]
  /// that resolves to a [CompactDioResult] containing the response data of type [R].
  ///
  /// [params] is an optional map of query parameters to include in the request.
  /// [baseUrl] is an optional base URL to use for the request.
  /// [dialog] is an optional boolean that determines whether to show a loading dialog.
  /// [decoder] is an optional [BaseDecoder] to use for decoding the response data.
  /// [decodeType] is an optional type parameter [T] used for decoding the response data.
  /// [contentType] is an optional content type to set for the request.
  /// [cancelToken] is an optional [CancelToken] that can be used to cancel the request.
  /// [onSendProgress] is an optional callback that is called periodically with the number of bytes sent.
  /// [onReceiveProgress] is an optional callback that is called periodically with the number of bytes received.
  static Future<CompactDioResult<R>> post<R, T>(
    String path, {
    Map<String, dynamic>? params,
    String? baseUrl,
    bool? dialog,
    BaseDecoder? decoder,
    dynamic data,
    T? decodeType,
    String? contentType,
    CancelToken? cancelToken,
    ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
  }) {
    return CompactDioProxy.instance.post<R, T>(
      path,
      params: params,
      baseUrl: baseUrl,
      dialog: dialog,
      decoder: decoder,
      data: data,
      type: decodeType,
      cancelToken: cancelToken,
      contentType: contentType,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );
  }

  /// Sends a PUT request to the specified [path] with the given [data] and returns a [Future]
  /// that resolves to a [CompactDioResult] containing the response data of type [R].
  ///
  /// [params] is an optional map of query parameters to include in the request.
  /// [baseUrl] is an optional base URL to use for the request.
  /// [dialog] is an optional boolean that determines whether to show a loading dialog.
  /// [decoder] is an optional [BaseDecoder] to use for decoding the response data.
  /// [decodeType] is an optional type parameter [T] used for decoding the response data.
  /// [contentType] is an optional content type to set for the request.
  /// [cancelToken] is an optional [CancelToken] that can be used to cancel the request.
  /// [onSendProgress] is an optional callback that is called periodically with the number of bytes sent.
  /// [onReceiveProgress] is an optional callback that is called periodically with the number of bytes received.
  static Future<CompactDioResult<R>> put<R, T>(
    String path, {
    Map<String, dynamic>? params,
    String? baseUrl,
    bool? dialog,
    BaseDecoder? decoder,
    dynamic data,
    T? decodeType,
    String? contentType,
    CancelToken? cancelToken,
    ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
  }) {
    return CompactDioProxy.instance.put<R, T>(
      path,
      params: params,
      baseUrl: baseUrl,
      dialog: dialog,
      decoder: decoder,
      data: data,
      type: decodeType,
      cancelToken: cancelToken,
      contentType: contentType,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );
  }

  /// Sends a DELETE request to the specified [path] and returns a [Future] that resolves
  /// to a [CompactDioResult] containing the response data of type [R].
  ///
  /// [params] is an optional map of query parameters to include in the request.
  /// [baseUrl] is an optional base URL to use for the request.
  /// [dialog] is an optional boolean that determines whether to show a loading dialog.
  /// [decoder] is an optional [BaseDecoder] to use for decoding the response data.
  /// [decodeType] is an optional type parameter [T] used for decoding the response data.
  /// [contentType] is an optional content type to set for the request.
  /// [cancelToken] is an optional [CancelToken] that can be used to cancel the request.
  /// [onSendProgress] is an optional callback that is called periodically with the number of bytes sent.
  /// [onReceiveProgress] is an optional callback that is called periodically with the number of bytes received.
  static Future<CompactDioResult<R>> delete<R, T>(
    String path, {
    Map<String, dynamic>? params,
    String? baseUrl,
    bool? dialog,
    BaseDecoder? decoder,
    T? decodeType,
    String? contentType,
    CancelToken? cancelToken,
    ProgressCallback? onSendProgress,
    ProgressCallback? onReceiveProgress,
  }) {
    return CompactDioProxy.instance.delete<R, T>(
      path,
      params: params,
      baseUrl: baseUrl,
      dialog: dialog,
      decoder: decoder,
      type: decodeType,
      cancelToken: cancelToken,
      contentType: contentType,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );
  }
}
